package com.sk.weichat.adapter;

import android.content.Context;
import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.sk.weichat.AppConfig;
import com.sk.weichat.R;
import com.sk.weichat.bean.SearchUserAndRoomBean;
import com.sk.weichat.helper.AvatarHelper;
import com.sk.weichat.ui.base.CoreManager;
import com.sk.weichat.view.ExpandableTextView;

import java.util.List;

public class SearchRoomAdapter extends BaseQuickAdapter<SearchUserAndRoomBean.RoomsBean, BaseViewHolder> {
    private CoreManager coreManager;
    public SearchRoomAdapter(CoreManager coreManager,List<SearchUserAndRoomBean.RoomsBean> data) {
        super(R.layout.item_search_room,data);
        this.coreManager = coreManager;
    }

    @Override
    protected void convert(BaseViewHolder helper, SearchUserAndRoomBean.RoomsBean item) {
        helper.addOnClickListener(R.id.layout_search_group_item)
                .addOnClickListener(R.id.tv_search_add);

        helper.setText(R.id.tv_search_nickname,item.getName());
        helper.setText(R.id.tv_group_numble,item.getUserSize()+"人");
        ImageView imgAvatar = helper.getView(R.id.img_search_avatar);
        ExpandableTextView tvContent = helper.getView(R.id.tv_content);
        AvatarHelper.getInstance().displayUrl(coreManager.readConfigBean().getDownloadAvatarUrl() +item.gettGroupHeads(),imgAvatar,R.drawable.groupdefault);
        if (TextUtils.isEmpty(item.getDesc())){
            tvContent.setText("群主很懒，还没有群介绍哦~");
        }else {
            tvContent.setText(item.getDesc());
        }

    }
}
